﻿using UnityEngine;
using System.Collections;

public class EventTweenBase : MonoBehaviour {
	protected float SaveTime;
	public float AniTime = 1;
	public ValueEvent.EaseType easyType;
	public WrapMode m_Wrap = WrapMode.PingPong;
	public float m_DelayTime;
	public bool m_PlayStart;
	// Use this for initialization
	void Start () {
		SaveTime = Time.time;
	}
	
	// Update is called once per frame
	void Update () {
		if (m_Wrap == WrapMode.Clamp && Time.time - SaveTime - m_DelayTime > AniTime)
			GameObject.Destroy (this);
		UpdateEvent ();

	}
	protected virtual void UpdateEvent(){

	}
	protected bool CanTween{
		get{ 
			return Time.time - SaveTime > m_DelayTime;
		}
	}
	protected float EventTime{
		get{
			float time;
			time = ValueEvent.WrapValue ((Time.time - SaveTime - m_DelayTime)/AniTime,0,1, m_Wrap);
			return time;
		}
	}
}
